package cn.vshare.service.impl;

import cn.vshare.dao.TradeDao;
import cn.vshare.entity.Trade;
import cn.vshare.service.TradeService;
import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;

@Service
public class TradeServiceImpl implements TradeService {
    @Autowired
    private TradeDao tradeDao;
    @Override
    public void addTrade(Trade trade) {
        tradeDao.addTrade(trade);
    }

    @Override
    public Page<Trade> getTradeByDynamic(Map map) {
        String pageNo1= (String) map.get("pageNo");
       String pageSize2= (String) map.get("pageSize");
        int pageNo=Integer.parseInt(pageNo1);
        int pageSize=Integer.parseInt(pageSize2);
        Page<Trade> page=PageHelper.startPage(pageNo,pageSize);
        List<Trade> list=tradeDao.getTradeByDynamic(map);
        int total=tradeDao.getTradeCountByDynamic(map);
        page.setTotal(total);
        return page;
    }

    @Override
    public Integer countTradeMoney(Map<String,Object> map) {
        return tradeDao.countTradeMoney(map);
    }
}
